package com.hcs.chenyu.confessionwall;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import com.hcs.chenyu.R;

import java.text.SimpleDateFormat;
import java.util.Date;

public class confessionwall extends AppCompatActivity {
    private EditText mconfessionwalledbtn;
    private Button mconfessionwallbtncommit;
    private ImageButton mmtouxiangkuang;
    private TextView mmtouxiangmingzi;
    private TextView mmtouxiangduihuakuang;
    private ImageButton mconfessionwallimbtn;
    private TextView mdatatimetv;
    private Button mmoremessagebtn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_confessionwall);
        initview();
        mmoremessagebtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(confessionwall.this,messageall.class);
                startActivity(intent);
            }
        });
    }

    @SuppressLint("WrongViewCast")
    private void initview() {
        mconfessionwalledbtn = findViewById(R.id.confessionwalledbtn);
        mmtouxiangduihuakuang = findViewById(R.id.mtouxiangduihuakuang);
        mmtouxiangkuang = findViewById(R.id.mtouxiangkuang);
        mmtouxiangmingzi = findViewById(R.id.mtouxiangmingzi);
        mdatatimetv = findViewById(R.id.mdatatimetv);
        mmoremessagebtn = findViewById(R.id.mmoremessagebtn);
        mconfessionwallimbtn = findViewById(R.id.confessionwallimbtn);
        mconfessionwallbtncommit = findViewById(R.id.confessionwallbtncommit);
        mconfessionwallbtncommit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mmtouxiangduihuakuang.setVisibility(View.VISIBLE);
                mmtouxiangkuang.setVisibility(View.VISIBLE);
                mmtouxiangmingzi.setVisibility(View.VISIBLE);
                String biaobai = mconfessionwalledbtn.getText().toString().trim();
                mmtouxiangduihuakuang.setText(biaobai);
                mdatatimetv.setVisibility(View.VISIBLE);
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");// HH:mm:ss
               //获取当前时间
                Date date = new Date(System.currentTimeMillis());
                mdatatimetv.setText(simpleDateFormat.format(date));
                mconfessionwalledbtn.setText("");
            }
        });
        mconfessionwallimbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog dialog;
                AlertDialog.Builder builder = new AlertDialog.Builder(confessionwall.this)
                        .setTitle("表情选择框").setIcon(R.drawable.ic_launcher_foreground)
                        .setMessage("是否选择表情")
                        .setPositiveButton("确定", (dialog1, which) -> finish())
                        .setNegativeButton("取消", (dialog12, which) -> dialog12.dismiss());
                dialog = builder.create();
                dialog.show();
            }
        });
    }

}